# 返回日期填0
from datetime import datetime

import pandas as pd


def get_day(d):
    if d < 10:
        return f'0{d}'
    else:
        return d


def generate_pg_create_table_sql(field_names, table_name):
    """
    生成 PostgreSQL 创建表的 SQL 语句，所有字段类型为 varchar(255)
    :param field_names: 字段名列表
    :param table_name: 表名
    :return: 创建表的 SQL 语句
    """
    field_definitions = ', '.join([f"{field} varchar(255)" for field in field_names])
    sql = f"CREATE TABLE {table_name} ({field_definitions});"
    return sql


def to_date(specified_date_str) -> datetime:
    # 将字符串转换为 datetime 对象
    specified_date = datetime.strptime(specified_date_str, "%Y-%m-%d")
    return specified_date


if __name__ == '__main__':
    file_path = r"D:\temp\wlan.csv"
    # 只读取 0 行数据，从而仅获取表头
    df = pd.read_csv(file_path, nrows=0)
    headers = df.columns.tolist()
    print(generate_pg_create_table_sql(headers, "wlan"))
